import java.io.IOException;
import java.util.logging.FileHandler;
/*
 * Logger.java
 *
 */

class Logger {

    private static String LOG_PREFIX_INFO = "I: ";
    private static String LOG_PREFIX_WARN = "W: ";
    private static String LOG_PREFIX_ERROR = "E: ";
    private static String LOG_PREFIX_SEVERE = "S: ";
	private static String LOG_NAME = "TaskoLogger";
    
	private static java.util.logging.Logger log = java.util.logging.Logger.getLogger(LOG_NAME);
	/**
	 * 
	 * @param logFileName 
	 * The logFileName is the path of the log file where the logs pertaining to a specific feature are stored. Eg. "fileOperations.log" or "deleteTask.log" 
	 */
    public Logger(String logFileName) {
    	try {
			FileHandler handler = new FileHandler(logFileName);
			log.addHandler(handler);
		} catch (SecurityException e) {
			this.logEventError(e.getMessage());
		} catch (IOException e) {
			this.logEventError(e.getMessage());
		}
    }

    // -----------------------------------------------------------------------------
    // Quick Access to Logging.

    public void logEventInfo(String eventData) {
        log.info(LOG_PREFIX_INFO + eventData);
    }

    public void logEventWarn(String eventData) {
    	log.warning(LOG_PREFIX_WARN + eventData);
    }

    public void logEventError(String eventData) {
        log.severe(LOG_PREFIX_ERROR + eventData);
    }

    public void logEventSevere(String eventData) {
        log.severe(LOG_PREFIX_SEVERE + eventData);
    }

}
